//
//@File    :	4.22_delete.cpp
//@Time    :	2021/08/04 17:13:48
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	using the delete operator
//

#include <cstring>
#include <iostream>
using namespace std;
char *getname(void);
int main()
{
    char * name;

    name = getname();
    cout<<name<<" at "<<(int*)name<<"\n";
    delete [] name;

    name = getname();
    cout<<name<<" at "<<(int*)name<<"\n";
    delete [] name;
    system("pause");
    return 0;
}
char * getname()
{
    char temp[80];
    cout<<"Enter last name:";
    cin>>temp;
    char*pn = new char[strlen(temp)+1];
    strcpy(pn,temp);

    return pn;
}